package com.bw.image.imageUtils

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.bw.image.R

/**
 * 封装图片
 */
object GlideUtils {
    //加载图片
    fun loadImage(context : Context, image:ImageView, url:String){
        Glide.with(context).load(url)
            .error(com.blankj.utilcode.R.drawable.notification_bg)
            .placeholder(com.blankj.utilcode.R.drawable.notification_bg)
            .into(image)
    }


    //图片圆片
    fun loadCircleImage(image:ImageView,url:String){
        Glide.with(image).load(url)
            .error(com.blankj.utilcode.R.drawable.notification_bg)
            .placeholder(com.blankj.utilcode.R.drawable.notification_bg)
            .circleCrop()
            .into(image)
    }


    //圆角圆片
    fun loadRoundImage(image:ImageView,url:String,corners:Int){
        Glide.with(image).load(url)
            .error(com.blankj.utilcode.R.drawable.notification_bg)//错误的时候显示这个图片
            .placeholder(com.blankj.utilcode.R.drawable.notification_bg)//站位图  未加载出图片会先显示这个图片
            .transform(RoundedCorners(corners))//圆角度
            .into(image)
    }
}